//
//  CountDownViewController.m
//  DayDayRun
//
//  Created by 卫建 on 16/1/11.
//  Copyright © 2016年 卫建. All rights reserved.
//

#import "CountDownViewController.h"
#import "AreaViewController.h"
//#import "RunningMapViewController.h"
@interface CountDownViewController ()
@property (strong, nonatomic) IBOutlet UILabel *countLabel;
@property (strong, nonatomic) IBOutlet UIView *countView;

@property(nonatomic,strong)NSTimer *countDownTimer;

@property(nonatomic,assign)NSInteger time;

@end

@implementation CountDownViewController



- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.time = 4;
    
    self.countDownTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(updateTime) userInfo:nil repeats:YES];
    [[NSRunLoop currentRunLoop] addTimer:self.countDownTimer forMode:NSRunLoopCommonModes];
    
}

#pragma mark--------显示时间的方法
- (void)updateTime
{
    AreaViewController *AreaVC = [[AreaViewController alloc] init];
    
    switch (self.time)
    {
        case 1:
            
            [self presentViewController:AreaVC animated:YES completion:^{
                
            }];
            
        break;
            
    }
    
    
//    RunningMapViewController *runningMap = [[RunningMapViewController alloc]init];
//    // runningMap.runNum = _runNum;
//    
//    runningMap.isValue =nil;
//    runningMap.isKey = @"0";
//    
//    [self.navigationController pushViewController:runningMap animated:YES];
    
    
    __weak typeof(self) weakSelf = self;
    
    
    [UILabel animateWithDuration:1 delay:0 options:UIViewAnimationOptionTransitionFlipFromBottom animations:^{
        
//        weakSelf.countLabel.bounds = [UIScreen mainScreen].bounds;
//        
//        weakSelf.countLabel.font = [UIFont systemFontOfSize:200];
        
    } completion:^(BOOL finished) {
        
        
        weakSelf.countLabel.font = [UIFont systemFontOfSize:200];
        
        
        self.time -= 1;
        
        NSString *timeStr = [NSString stringWithFormat:@"%ld",(long)self.time];
        
        self.countLabel.text = timeStr;
        
//        NSLog(@"%@",self.countLabel.text);

        
    }];

    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}



@end
